/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ui.controllers;

import bl.controllers.UserJpaController;
import entities.User;
import java.util.Collection;
import java.util.Iterator;

/**
 *
 * @author Spyros
 */
public class LoginController {

    public Integer login(String username, String password){
        UserJpaController userJpaController = new UserJpaController();
        Collection<User> users = userJpaController.findUserEntities();
        for (Iterator<User> it = users.iterator(); it.hasNext();) {
            User user = it.next();
            if (user.getUsername().equals(username.trim()) && user.getPassword().equals(password.trim())){
                return user.getId();
            }
        }
        return null;
    }

}
